<?php
namespace app\manage\controller;

use think\Controller;
use think\Request;
use think\Validate;
use think\Db;
use Config;

/**合同管理
 * Class UnitBuilding
 * @package app\manage\controller
 */
class Payment extends Controller{

  /*  public function pay(){
        $i="";
        $data=base64_image_content($i);
        var_dump($data);exit;

    }*/
    /**
     * 租房示
     * @return \think\response\Json
     */
    public function PayList(){
        $model=new \app\manage\model\Payment();
        $date=$model->index();
        returnJson(200,"成功",$date)->send();die;
    }

    /**
     * 查看租房
     */
    public function PayOne()
    {
        $model=new \app\manage\model\Payment();
        $data = input();
        $h_id = trim($data['c_id']);
        $data = $model->PayOne($h_id);
        //判断后台有没有设置单元楼栋数
        if ($data == 2) {
            returnJson(-411, "合同不存在")->send();
            die;
        } else {
            returnJson(200, "成功", $data)->send();
            die;
        }
    }

    /**
     * 确认缴费
     * @return \think\response\Json
     */
    public function PayConfirm(){
        $model=new \app\manage\model\Payment();
        $input = input();
        $p_id = trim( $input['pay_id'] );//缴费id
        $c_id = trim( $input['c_id'] );//合同id
        if($c_id==null || $p_id==null){
            returnJson(-423,"数据不对")->send();die;
        }
        $date=$model->Confirm($p_id,$c_id);
        if($date){
            returnJson(200,"成功")->send();die;
        }else{
            returnJson(-444,"失败")->send();die;
        }
    }
    /**
     * 退租确认缴费
     * @return \think\response\Json
     */
    public function rentWithdrawal(){
        $model=new \app\manage\model\Payment();
        $input = input();
        $c_id = trim( $input['c_id'] );//合同id
        $type = trim( $input['type'] );//合同id
        $date=$model->rentWithdrawal($c_id,$type);
        if($date){
            returnJson(200,"成功")->send();die;
        }else{
            returnJson(-444,"失败")->send();die;
        }
    }
    /**
     * 退房查看
     * @return \think\response\Json
     */
    public function PayRentWithdrawal(){
        $model=new \app\manage\model\Payment();
        $input = input();
        $c_id = trim( $input['c_id'] );//合同id
        $date=$model->PayRentWithdrawal($c_id);
        if($date){
            returnJson(200,"成功",$date)->send();die;
        }else{
            returnJson(-444,"失败")->send();die;
        }
    }


}